import scrapy
from wwwjj20com.items import Wwwjj20ComItem
from scrapy.http import Request


class MySpiderSpider(scrapy.Spider):
    name = 'my_spider'
    allowed_domains = ['jj20.com']
    start_urls = ['http://www.jj20.com/bz/nxxz/']

    def parse(self, response):
        item = Wwwjj20ComItem()
        item['picurl'] = response.xpath('//div[@class="g-box-1200"]/ul/li/a/img/@src').extract()
        print(item['picurl'])
        item['title'] = response.xpath('//div[@class="g-box-1200"]/ul/li/a/img/@alt').extract()
        yield item

        for i in range(1,5):
            nexturl = "http://www.jj20.com/bz/nxxz/shxz/list_62_cc_13_"+str(i)+".html"
            #http://www.jj20.com/bz/nxxz/list_7_cc_14_4.html
            #http://www.jj20.com/bz/nxxz/shxz/list_62_cc_13_2.html
            #http://www.jj20.com/bz/nxxz/shxz/list_62_cc_13_3.html
            #http://www.jj20.com/bz/nxxz/shxz/list_62_cc_13_4.html
            yield Request(nexturl,callback=self.parse)
